<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">











<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>resource-processor - </title>
    <style type="text/css" media="all">
      @import url("./css/maven-base.css");
      @import url("./css/maven-theme.css");
      @import url("./css/site.css");
    </style>
    <link rel="stylesheet" href="./css/print.css" type="text/css" media="print" />
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      </head>
  <body class="composite">
    <div id="banner">
                    <span id="bannerLeft">
    
            resource-processor
    
            </span>
                    <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="breadcrumbs">
          
  

  
    
  
  
    
            <div class="xleft">
        Last Published: 2010-09-12
                      </div>
            <div class="xright">      
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
    <div id="leftColumn">
      <div id="navcolumn">
           
  

  
    
  
  
    
                   <h5>Overview</h5>
            <ul>
              
    <li class="none">
                    <a href="project-summary.html">Summary</a>
          </li>
              
    <li class="none">
              <strong>usage 1.1 (old)</strong>
        </li>
              
    <li class="none">
                    <a href="usage1_2.html">usage 1.2</a>
          </li>
          </ul>
              <h5>Summary</h5>
            <ul>
              
    <li class="none">
                    <a href="dependencies.html">Dependencies</a>
          </li>
              
    <li class="none">
                    <a href="source-repository.html">Source</a>
          </li>
          </ul>
                                           <a href="http://maven.apache.org/" title="Built by Maven" class="poweredBy">
            <img alt="Built by Maven" src="./images/logos/maven-feather.png"></img>
          </a>
                       
  

  
    
  
  
    
        </div>
    </div>
    <div id="bodyColumn">
      <div id="contentBox">
        <div class="section"><h2>Introduction</h2>
<p>This plugin is designed to be used joined with a <a href="http://code.google.com/p/maven-annotation-plugin/" class="externalLink">maven-annotation-plugin</a></p>
</div>
<div class="section"><h2>Usage</h2>
<p>To use processor you have to do the following steps:</p>
<ol type="1"><li>Create a file containing messages. </li>
<li>Add dependency of processor in your POM.</li>
<li>Decorate a (chosen) class with the <b>@ResourceBundle</b> annotation. </li>
<li>Run processor using maven-annotation-plugin.</li>
</ol>
<ul><li><b>Create a file containing messages</b><p>The messages must be put in the properties file named <b>messages.properties</b>. This file must be <b>reachable from classpath</b> and the name of each property must be compliant with <b>java method name syntax</b> otherwise will be ignored</p>
</li>
<li><b>Add dependency of processor in your POM</b><p>Add to your pom the following dependency</p>
<div class="source"><pre>
    &lt;dependency&gt;
          &lt;groupId&gt;org.bsc.processor&lt;/groupId&gt;
          &lt;artifactId&gt;resource-processor&lt;/artifactId&gt;
          &lt;version&gt;1.0&lt;/version&gt;
          &lt;type&gt;jar&lt;/type&gt;
          &lt;optional&gt;true&lt;/optional&gt;&lt;!-- Optional avoid to include dependency in transitive mode --&gt; 
    &lt;/dependency&gt;
</pre>
</div>
<p>And add repository declaration </p>
<div class="source"><pre>
&lt;repositories&gt;
    &lt;repository&gt;
      &lt;id&gt;internationalization-processor&lt;/id&gt;
      &lt;url&gt;http://internationalization-processor.googlecode.com/svn/mavenrepo&lt;/url&gt;
    &lt;/repository&gt;
&lt;/repositories&gt;
</pre>
</div>
</li>
<li><b>Decorate a (chosen) class with the @ResourceBundle annotation</b><p>Choose a class and decorate it with the @ResourceBundle annotation (see example below)</p>
<div class="source"><pre>
@ResourceBundle
public class ProcessorTest {

}
</pre>
</div>
<p>The processor automatically will generate the class &lt;class name&gt;Messages.java </p>
</li>
<li><b>Run processor using maven-annotation-plugin</b><div class="source"><pre>
&lt;/plugin&gt;
    &lt;plugin&gt;
      &lt;groupId&gt;org.bsc.maven&lt;/groupId&gt;
      &lt;artifactId&gt;maven-processor-plugin&lt;/artifactId&gt;
      &lt;version&gt;1.3.1&lt;/version&gt;
      &lt;executions&gt;
        &lt;execution&gt;
          &lt;id&gt;process&lt;/id&gt;
          &lt;goals&gt;
            &lt;goal&gt;process&lt;/goal&gt;
          &lt;/goals&gt;
          &lt;phase&gt;generate-sources&lt;/phase&gt;
          &lt;configuration&gt;
             &lt;outputDirectory&gt;${basedir}/target/generated-sources/processor&lt;/outputDirectory&gt;
              
             &lt;!-- failOnError&gt;true&lt;/failOnError --&gt;
              
             &lt;processors&gt;
             &lt;!-- list of processors to use --&gt;
                &lt;processor&gt;org.bsc.processor.implementation.ResourceProcessorImpl&lt;/processor&gt;
            &lt;/processors&gt;  
          &lt;/configuration&gt;

        &lt;/execution&gt;
      &lt;/executions&gt;
    &lt;/plugin&gt;
</pre>
</div>
<p>And add the plugin repository declaration</p>
<div class="source"><pre>
&lt;pluginRepositories&gt;
    &lt;pluginRepository&gt;
      &lt;id&gt;maven-annotation-plugin&lt;/id&gt;
      &lt;url&gt;http://maven-annotation-plugin.googlecode.com/svn/trunk/mavenrepo&lt;/url&gt;
    &lt;/pluginRepository&gt;
&lt;/pluginRepositories&gt;
</pre>
</div>
</li>
</ul>
</div>

      </div>
    </div>
    <div class="clear">
      <hr/>
    </div>
    <div id="footer">
      <div class="xright">&#169;  
          2010
    
          
  

  
    
  
  
    
  </div>
      <div class="clear">
        <hr/>
      </div>
    </div>
  </body>
</html>
